﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Quality_Calculator.Skills.Carpenter
{
    class Rumination : SkillBase
    {
        private int Usage { get; set; }
        private int TotalCpReturned { get; set; }

        public double AvgCpReturned
        {
            get
            {
                return (double)TotalCpReturned / (double)Usage;
            }
        }

        public Rumination()
        {
            Icon = global::Quality_Calculator.Properties.Resources.Rumination;
            Name = "Rumination";
        }
        public override void SpellEffect(Synthesis synth)
        {
            Usage++;
            if(!synth.HasBuff(eSpell.InnerQuiet)) return;
            if (synth.InnerQuietStacks >= 10) synth.CPCurrent += 60;
            else
            {
                int returnedCp = (21 * synth.InnerQuietStacks - (int)Math.Pow(synth.InnerQuietStacks, 2) + 10) / 2;
                TotalCpReturned += returnedCp;
                synth.CPCurrent += returnedCp;
            }
            if (synth.CPCurrent >= synth.CPMax) synth.CPCurrent = synth.CPMax;
            synth.InnerQuietStacks = 0;
            synth.Buffs.RemoveAll(p => p.Spell.Enum == eSpell.InnerQuiet);
        }
    }
}
